package cn.hc.conn1;

import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

import java.io.IOException;

/**
 * @author huangchao E-mail:fengquan8866@163.com
 * @version 创建时间：2024/10/8 16:34
 */
public class HBaseConnection2 {

    public static Connection connection = null;

    static {
        // 1.创建连接
        // 默认使用同步连接
        try {
            // 使用读取本地文件的形式添加参数
            connection = ConnectionFactory.createConnection();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static void closeConnection() throws IOException {
        if (connection != null) connection.close();
    }

    public static void main(String[] args) throws IOException {
        // 直接使用创建的连接
        System.out.println(connection);

        closeConnection();
    }
}
